<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>首页</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css">
		<link rel="stylesheet" href="style/plugin/swiper/css/swiper.min.css" />
		<link rel="stylesheet" href="style/css/home.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="style/plugin/swiper/js/swiper.min.js"></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/md5.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
	</head>
	<body>
		<!-- Swiper -->
		<div id="news">
		    <div class="swiper-container">
				<div class="swiper-wrapper">
					<div class="swiper-slide" v-for="(img, index) in imgMsg" :key="index" v-if="imgMsg.length!=0"><img :src="htp+img.pic" /></div>
					<!--<div class="swiper-slide"><img src="style/img/swiper2.jpg" /></div>
					<div class="swiper-slide"><img src="style/img/swiper1.jpg" /></div>-->
				</div>
				<!-- Add Pagination -->
				<div class="swiper-pagination"></div> 
			</div>
			<!--资讯-->
			<div class="express-news">
				<a class=" news-tit" href="#">
					<img src="style/img/notice_home.png">
				</a>
				<div class="news-list-wrapper"> 
					<ul class="news-list">
	
						<li class="news-item" v-for="(notify,index) in noticeList" v-if="noticeList!=''">
							<a href="javascript:;" @tap="jumpNotice">
								{{notify.content}}
							</a>
						</li> 
					</ul>
				</div>
				<a class=" news-more" href="javascript:;" @tap="jumpNotice">
					<i class="line"></i>更多</a>
			</div>
	
			<!--news列表-->
			<div class="news">
				<h2 class="title nextArrow">最新新闻<a class=" more fr gray " href="javascript:;" @tap="jumpNews">查看更多</a></h2>
				<ul class="list">
					<li v-for="(news,index) in newList" @tap="jumpNewsDetail(index)" v-if="newList!=''">
						<a href="javascript:;">
							<img :src="htp+news.thumb_pic" class="list_left_img">
							<div class="list_right_text">
								<h2>{{news.title}}</h2>
								<p class="ellipsis" v-text="repalceHtml(news.content)">  
								</p>
							</div>
						</a>
					</li>
				</ul>
			</div>	
		</div>
		<!--footer-->
		<div class="footer" id="footer">
			<ul class="clearfix">
				<li>
					<a href='recommend_index.html' ;><i class="icon_home"></i><span  class="active_color">首页</span></a>
				</li>
				<li>
					<a href="recommend.html"><i class="icon_recommend"></i><span>推荐</span></a>
				</li>
				<li>
					<a href='recommend_mall.html' ;><i class="icon_integral"></i><span>积分</span></a>
				</li>
				<li>
					<a href='recommend_my.html' ;><i class="icon_my"></i><span>我的</span></a>
				</li>
			</ul>
		</div>
	</body>
	<script>
		// 资讯滚动
		function AutoScroll(obj) {
			$(obj).find(".news-list").animate({
				marginTop: "-22px"
			}, 500, function() {
				$(this).css({
					marginTop: "0px"
				}).append($(this).find("li:first"));
			});
		}
		$(document).ready(function() {
			setInterval('AutoScroll(".news-list-wrapper")', 2000)
		});
		$(".latest li img").next().css("color", "#1c1c1c")

		//search框跳转页面
		$(".inputsearch").focus(function() {
			document.activeElement.blur();
			location.href = "search.html"
		})
		
		new Vue({
			el:"#news",
			data:{
				imgMsg: [],
				noticeList:"",
				newList:"",
				htp:"",
				ticket:"",
				sign:""
			},
			methods:{ 
				jumpNotice:function(){
					mui.plusReady(function(){
						openurl("notice")//跳转页面
					})
				},
				jumpNoticeDetail:function(nIndex){
					//alert(nIndex)
					var nId=this.noticeList[nIndex].id;
					mui.plusReady(function(){
						//openurl("new_details")
						mui.openWindow({
							url:"new_details.html",//跳转页面
							extras:{
								name:nId//传参
							},
							waiting:{
                                autoShow:false//自动显示等待框，默认为true
                            }
						})
					})
				},
				jumpNews:function(){ 
					mui.plusReady(function(){
						openurl("news")
					})
				},
				jumpNewsDetail:function(newIndex){
					var nId=this.newList[newIndex].id;
					mui.plusReady(function(){
						mui.openWindow({
							url:"new_details.html",
							extras:{
								name:nId
							},
							waiting:{
                                autoShow:false//自动显示等待框，默认为true
                            }
						})
					})
				}
			},
			created:function(){
				this.ticket=localStorage.getItem("tick")
                this.sign=localStorage.getItem("sig")
				this.$http.post(domain+"/picture/getList?t="+this.ticket+"&sign="+this.sign,{scope:0},{emulateJSON:true}).then(//获取轮播图
		            function (res) {
		                // 处理成功的结果
		                if(res.body.code==1){
		                  console.log(res.body)	
		                  this.imgMsg=res.body.data.list;
		                } 
		            },function (res) {
		            // 处理失败的结果
		            console.log(res) 
		            }
		        );
				this.$http.post(domain+"/member_msg/getList?t="+this.ticket+"&sign="+this.sign,{
					page:1,
					page_size:3,
					type:-1
				},{emulateJSON:true}).then(//获取快讯数据
		            function (res) {
		                // 处理成功的结果
		                if(res.body.code==1){
		                  console.log(res.body)	
		                  this.noticeList=res.body.data.list;
		                } 
		            },function (res) {
		            // 处理失败的结果
		            console.log(res) 
		            }
		        );
		        this.$http.post(domain+"/news/getList?t="+this.ticket+"&sign="+this.sign,{
		        	page_size:4
		        },{emulateJSON:true}).then(//获取新闻列表
		            function (res) {
		                // 处理成功的结果
		                if(res.body.code==1){
		                  console.log(res.body)	
		                  this.newList=res.body.data.list;
		                } 
		            },function (res) {
		            // 处理失败的结果
		            console.log(res)   
		            }
		        );
			},
			updated:function(){
				var swiper = new Swiper('.swiper-container', {
					spaceBetween: 30,
					centeredSlides: true,
					autoplay: {
						delay: 2500,
						disableOnInteraction: false,
					},
					pagination: {
						el: '.swiper-pagination',
						clickable: true,
					},
					navigation: {
						nextEl: '.swiper-button-next',
						prevEl: '.swiper-button-prev',
					},
				});

			},
			mounted:function(){
				this.htp=domain2
				
				mui.plusReady(function(){
			
			//          var wvs = plus.webview.all();//获取所有的窗口
			//        plus.webview.close(wvs[0]);//关闭欢迎页
			
			    //首页返回键处理  
			            //处理逻辑：2秒内，连续两次按返回键，则退出应用  
			            var first = null;  
			            mui.back=function(){
			            if(!first){  
			                    first = new Date().getTime();  
			                    mui.toast('再按一次退出应用');  
			                    setTimeout(function(){  
			                        first = null;  
			                    },2000);  
			                } else {  
			                    if(new Date().getTime() - first < 2000){  
			                        plus.runtime.quit();
			                        localStorage.removeItem("custInfo");
			                    }  
			                }  
			            }; 
			        })
			}
		})
	</script>

</html>